home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / edebug / cl-specs.el.z / cl-specs.el
Encoding:
Text File  |  1998-05-21  |  14.0 KB  |  478 lines

  1. ;; cl-specs.el - Edebug specs for cl.el
  2.  
  3. ;; Copyright (C) 1993 Free Software Foundation, Inc.
  4. ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu>
  5. ;; Keywords: lisp, tools, maint
  6.  
  7. ;; This file is part of XEmacs.
  8.  
  9. ;; XEmacs is free software; you can redistribute it and/or modify it
  10. ;; under the terms of the GNU General Public License as published by
  11. ;; the Free Software Foundation; either version 2, or (at your option)
  12. ;; any later version.
  13.  
  14. ;; XEmacs is distributed in the hope that it will be useful,
  15. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. ;; GNU General Public License for more details.
  18.  
  19. ;; You should have received a copy of the GNU General Public License
  20. ;; along with XEmacs; see the file COPYING.  If not, write to the Free
  21. ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  22. ;; 02111-1307, USA.
  23.  
  24. ;;; Synched up with: Not in FSF
  25.  
  26. ;;; Commentary:
  27.  
  28. ;; LCD Archive Entry:
  29. ;; cl-specs.el|Daniel LaLiberte|liberte@cs.uiuc.edu
  30. ;; |Edebug specs for cl.el
  31. ;; |$Date: 1994/02/21 21:26:33 $|$Revision: 1.1 $|~/modes/cl-specs.el|
  32.  
  33. ;; These specs are to be used with edebug.el version 3.3 or later and
  34. ;; cl.el version 2.03 or later, by Dave Gillespie <daveg@synaptics.com>.
  35.  
  36. ;; This file need not be byte-compiled, but it shouldn't hurt.
  37.  
  38. ;;; Code:
  39.  
  40. (provide 'cl-specs)
  41. ;; Do the above provide before the following require.
  42. ;; Otherwise if you load this before edebug if cl is already loaded
  43. ;; an infinite loading loop would occur.
  44. (require 'edebug)
  45.  
  46. ;; Blocks
  47.  
  48. (def-edebug-spec block (symbolp body))
  49. (def-edebug-spec return (&optional form))
  50. (def-edebug-spec return-from (symbolp &optional form))
  51.  
  52. ;; Loops
  53.  
  54. (def-edebug-spec when t)
  55. (def-edebug-spec unless t)
  56. (def-edebug-spec case (form &rest (sexp body)))
  57. (def-edebug-spec ecase case)
  58. (def-edebug-spec do
  59.   ((&rest &or symbolp (symbolp &optional form form))
  60.    (form body) 
  61.    cl-declarations body))
  62. (def-edebug-spec do* do)
  63. (def-edebug-spec dolist 
  64.   ((symbolp form &optional form) cl-declarations body))
  65. (def-edebug-spec dotimes dolist)
  66. (def-edebug-spec do-symbols
  67.   ((symbolp &optional form form) cl-declarations body))
  68. (def-edebug-spec do-all-symbols 
  69.   ((symbolp &optional form) cl-declarations body))
  70.  
  71. ;; Multiple values
  72.  
  73. (def-edebug-spec multiple-value-list (form))
  74. (def-edebug-spec multiple-value-call (function-form body))
  75. (def-edebug-spec multiple-value-bind 
  76.   ((&rest symbolp) form cl-declarations body))
  77. (def-edebug-spec multiple-value-setq ((&rest symbolp) form))
  78. (def-edebug-spec multiple-value-prog1 (form body))
  79.  
  80. ;; Bindings
  81.  
  82. (def-edebug-spec lexical-let let)
  83. (def-edebug-spec lexical-let* let)
  84.  
  85. (def-edebug-spec psetq setq)
  86. (def-edebug-spec progv (form form body))
  87.  
  88. (def-edebug-spec flet ((&rest (defun*)) cl-declarations body))
  89. (def-edebug-spec labels flet)
  90.  
  91. (def-edebug-spec macrolet 
  92.   ((&rest (&define name (&rest arg) cl-declarations-or-string def-body)) 
  93.    cl-declarations body))
  94.  
  95. (def-edebug-spec symbol-macrolet 
  96.   ((&rest (symbol sexp)) cl-declarations body))
  97.  
  98. (def-edebug-spec destructuring-bind
  99.   (&define cl-macro-list form cl-declarations def-body))
  100.  
  101. ;; Setf
  102.  
  103. (def-edebug-spec setf (&rest [place form])) ;; sexp is not specific enough
  104. (def-edebug-spec psetf setf)
  105.  
  106. (def-edebug-spec letf  ;; *not* available in Common Lisp
  107.   ((&rest (gate place &optional form))
  108.    body))
  109. (def-edebug-spec letf* letf)
  110.  
  111.  
  112. (def-edebug-spec defsetf 
  113.   (&define name 
  114.        [&or [symbolp &optional stringp]
  115.         [cl-lambda-list (symbolp)]]
  116.        cl-declarations-or-string def-body))
  117.  
  118. (def-edebug-spec define-setf-method 
  119.   (&define name cl-lambda-list cl-declarations-or-string def-body))
  120.  
  121. (def-edebug-spec define-modify-macro
  122.   (&define name cl-lambda-list ;; should exclude &key
  123.        symbolp &optional stringp))
  124.  
  125. (def-edebug-spec callf (function* place &rest form))
  126. (def-edebug-spec callf2 (function* form place &rest form))
  127.  
  128. ;; Other operations on places
  129.  
  130. (def-edebug-spec remf (place form))
  131.  
  132. (def-edebug-spec incf (place &optional form))
  133. (def-edebug-spec decf incf)
  134. (def-edebug-spec push (form place))
  135. (def-edebug-spec pushnew 
  136.   (form place &rest 
  137.     &or [[&or ":test" ":test-not" ":key"] function-form]
  138.     [keywordp form]))
  139. (def-edebug-spec pop (place))
  140.  
  141. (def-edebug-spec shiftf (&rest place))  ;; really [&rest place] form
  142. (def-edebug-spec rotatef (&rest place))
  143.  
  144.  
  145. ;; Functions with function args.  These are only useful if the
  146. ;; function arg is quoted with ' instead of function.
  147.  
  148. (def-edebug-spec some (function-form form &rest form))
  149. (def-edebug-spec every some)
  150. (def-edebug-spec notany some)
  151. (def-edebug-spec notevery some)
  152.  
  153. ;; Mapping
  154.  
  155. (def-edebug-spec map (form function-form form &rest form))
  156. (def-edebug-spec maplist (function-form form &rest form))
  157. (def-edebug-spec mapc maplist)
  158. (def-edebug-spec mapl maplist)
  159. (def-edebug-spec mapcan maplist)
  160. (def-edebug-spec mapcon maplist)
  161.  
  162. ;; Sequences
  163.  
  164. (def-edebug-spec reduce (function-form form &rest form))
  165.  
  166. ;; Types and assertions
  167.  
  168. (def-edebug-spec cl-type-spec (sexp)) ;; not worth the trouble to specify, yet.
  169.  
  170. (def-edebug-spec deftype defmacro*)
  171. (def-edebug-spec check-type (place cl-type-spec &optional stringp))
  172. ;; (def-edebug-spec assert (form &optional form stringp &rest form))
  173. (def-edebug-spec assert (form &rest form))
  174. (def-edebug-spec typecase (form &rest ([&or cl-type-spec "otherwise"] body)))
  175. (def-edebug-spec etypecase typecase)
  176.  
  177. (def-edebug-spec ignore-errors t)
  178.  
  179. ;; Time of Evaluation
  180.  
  181. (def-edebug-spec eval-when
  182.   ((&rest &or "compile" "load" "eval") body))
  183. (def-edebug-spec load-time-value (form &optional &or "t" "nil"))
  184.  
  185. ;; Declarations
  186.  
  187. (def-edebug-spec cl-decl-spec 
  188.   ((symbolp &rest sexp)))
  189.  
  190. (def-edebug-spec cl-declarations
  191.   (&rest ("declare" &rest cl-decl-spec)))
  192.  
  193. (def-edebug-spec cl-declarations-or-string
  194.   (&or stringp cl-declarations))
  195.  
  196. (def-edebug-spec declaim (&rest cl-decl-spec))
  197. (def-edebug-spec declare (&rest cl-decl-spec))  ;; probably not needed.
  198. (def-edebug-spec locally (cl-declarations &rest form))
  199. (def-edebug-spec the (cl-type-spec form))
  200.  
  201. ;;======================================================
  202. ;; Lambda things
  203.  
  204. (def-edebug-spec cl-lambda-list
  205.   (([&rest arg]
  206.     [&optional ["&optional" cl-&optional-arg &rest cl-&optional-arg]]
  207.     [&optional ["&rest" arg]]
  208.     [&optional ["&key" [cl-&key-arg &rest cl-&key-arg]
  209.         &optional "&allow-other-keywords"]]
  210.     [&optional ["&aux" &rest
  211.         &or (symbolp &optional def-form) symbolp]]
  212.     )))
  213.  
  214. (def-edebug-spec cl-&optional-arg
  215.   (&or (arg &optional def-form arg) arg))
  216.  
  217. (def-edebug-spec cl-&key-arg
  218.   (&or ([&or (symbolp arg) arg] &optional def-form arg) arg))
  219.  
  220. ;; The lambda list for macros is different from that of normal lambdas.
  221. ;; Note that &environment is only allowed as first or last items in the 
  222. ;; top level list.
  223.  
  224. (def-edebug-spec cl-macro-list
  225.   (([&optional "&environment" arg]
  226.     [&rest cl-macro-arg]
  227.     [&optional ["&optional" &rest 
  228.         &or (cl-macro-arg &optional def-form cl-macro-arg) arg]]
  229.     [&optional [[&or "&rest" "&body"] cl-macro-arg]]
  230.     [&optional ["&key" [&rest 
  231.             [&or ([&or (symbolp cl-macro-arg) arg] 
  232.                   &optional def-form cl-macro-arg)
  233.                  arg]]
  234.         &optional "&allow-other-keywords"]]
  235.     [&optional ["&aux" &rest
  236.         &or (symbolp &optional def-form) symbolp]]
  237.     [&optional "&environment" arg]
  238.     )))
  239.  
  240. (def-edebug-spec cl-macro-arg
  241.   (&or arg cl-macro-list1))
  242.  
  243. (def-edebug-spec cl-macro-list1
  244.   (([&optional "&whole" arg]  ;; only allowed at lower levels
  245.     [&rest cl-macro-arg]
  246.     [&optional ["&optional" &rest 
  247.         &or (cl-macro-arg &optional def-form cl-macro-arg) arg]]
  248.     [&optional [[&or "&rest" "&body"] cl-macro-arg]]
  249.     [&optional ["&key" [&rest 
  250.             [&or ([&or (symbolp cl-macro-arg) arg] 
  251.                   &optional def-form cl-macro-arg)
  252.                  arg]]
  253.         &optional "&allow-other-keywords"]]
  254.     [&optional ["&aux" &rest
  255.         &or (symbolp &optional def-form) symbolp]]
  256.     . [&or arg nil])))
  257.  
  258.  
  259. (def-edebug-spec defun*
  260.   ;; Same as defun but use cl-lambda-list.
  261.   (&define [&or name
  262.         ("setf" :name setf name)]
  263.        cl-lambda-list
  264.        cl-declarations-or-string
  265.        [&optional ("interactive" interactive)]
  266.        def-body))
  267. (def-edebug-spec defsubst* defun*)
  268.  
  269. (def-edebug-spec defmacro* 
  270.   (&define name cl-macro-list cl-declarations-or-string def-body))
  271. (def-edebug-spec define-compiler-macro defmacro*)
  272.  
  273.  
  274. (def-edebug-spec function*
  275.   (&or symbolp cl-lambda-expr))
  276.  
  277. (def-edebug-spec cl-lambda-expr
  278.   (&define ("lambda" cl-lambda-list
  279.         ;;cl-declarations-or-string
  280.         ;;[&optional ("interactive" interactive)]
  281.         def-body)))
  282.  
  283. ;; Redefine function-form to also match function*
  284. (def-edebug-spec function-form
  285.   ;; form at the end could also handle "function",
  286.   ;; but recognize it specially to avoid wrapping function forms.
  287.   (&or ([&or "quote" "function"] &or symbolp lambda-expr) 
  288.        ("function*" cl-lambda-expr)
  289.        form))
  290.  
  291. ;;======================================================
  292. ;; Structures
  293. ;; (def-edebug-spec defstruct (&rest sexp)) would be sufficient, but...
  294.  
  295. ;; defstruct may contain forms that are evaluated when a structure is created.
  296. (def-edebug-spec defstruct
  297.   (&define  ; makes top-level form not be wrapped
  298.    [&or symbolp
  299.     (gate
  300.      symbolp &rest 
  301.          (&or [":conc-name" &or stringp "nil"]
  302.               [":constructor" symbolp &optional cl-lambda-list]
  303.               [":copier" symbolp]
  304.               [":predicate" symbolp]
  305.               [":include" symbolp &rest sexp];; not finished
  306.               ;; The following are not supported.
  307.               ;; [":print-function" ...]
  308.               ;; [":type" ...]
  309.               ;; [":initial-offset" ...]
  310.               ))]
  311.    [&optional stringp]
  312.    ;; All the above is for the following def-form.
  313.    &rest &or symbolp (symbolp def-form &optional ":read-only" sexp)))
  314.  
  315. ;;======================================================
  316. ;; Loop
  317.  
  318. ;; The loop macro is very complex, and a full spec is found below.
  319. ;; The following spec only minimally specifies that
  320. ;; parenthesized forms are executable, but single variables used as
  321. ;; expressions will be missed.  You may want to use this if the full
  322. ;; spec causes problems for you.
  323.  
  324. (def-edebug-spec loop
  325.   (&rest &or symbolp form))
  326.  
  327. ;; Below is a complete spec for loop, in several parts that correspond
  328. ;; to the syntax given in CLtL2.  The specs do more than specify where
  329. ;; the forms are; it also specifies, as much as Edebug allows, all the
  330. ;; syntactically legal loop clauses.  The disadvantage of this
  331. ;; completeness is rigidity, but the "for ... being" clause allows
  332. ;; arbitrary extensions of the form: [symbolp &rest &or symbolp form].
  333.  
  334. (def-edebug-spec loop
  335.   ([&optional ["named" symbolp]]
  336.    [&rest 
  337.     &or
  338.     ["repeat" form]
  339.     loop-for-as
  340.     loop-with
  341.     loop-initial-final]
  342.    [&rest loop-clause]
  343.    ))
  344.  
  345. (def-edebug-spec loop-with
  346.   ("with" loop-var
  347.    loop-type-spec
  348.    [&optional ["=" form]]
  349.    &rest ["and" loop-var
  350.       loop-type-spec
  351.       [&optional ["=" form]]]))
  352.  
  353. (def-edebug-spec loop-for-as
  354.   ([&or "for" "as"] loop-for-as-subclause
  355.    &rest ["and" loop-for-as-subclause]))
  356.  
  357. (def-edebug-spec loop-for-as-subclause
  358.   (loop-var 
  359.    loop-type-spec
  360.    &or 
  361.    [[&or "in" "on" "in-ref" "across-ref"]
  362.     form &optional ["by" function-form]]
  363.  
  364.    ["=" form &optional ["then" form]]
  365.    ["across" form]
  366.    ["being" 
  367.     [&or "the" "each"]
  368.     &or 
  369.     [[&or "element" "elements"] 
  370.      [&or "of" "in" "of-ref"] form
  371.      &optional "using" ["index" symbolp]];; is this right?
  372.     [[&or "hash-key" "hash-keys"
  373.       "hash-value" "hash-values"]
  374.      [&or "of" "in"]
  375.      hash-table-p &optional ["using" ([&or "hash-value" "hash-values" 
  376.                        "hash-key" "hash-keys"] sexp)]]
  377.                     
  378.     [[&or "symbol" "present-symbol" "external-symbol"
  379.       "symbols" "present-symbols" "external-symbols"]
  380.      [&or "in" "of"] package-p]
  381.      
  382.     ;; Extensions for Emacs Lisp, including Lucid Emacs.
  383.     [[&or "frame" "frames"
  384.       "screen" "screens"
  385.       "buffer" "buffers"]]
  386.  
  387.     [[&or "window" "windows"] 
  388.      [&or "of" "in"] form]
  389.  
  390.     [[&or "overlay" "overlays"
  391.       "extent" "extents"]
  392.      [&or "of" "in"] form
  393.      &optional [[&or "from" "to"] form]]
  394.  
  395.     [[&or "interval" "intervals"] 
  396.      [&or "in" "of"] form
  397.      &optional [[&or "from" "to"] form]
  398.      ["property" form]]
  399.      
  400.     [[&or "key-code" "key-codes"
  401.       "key-seq" "key-seqs"
  402.       "key-binding" "key-bindings"] 
  403.      [&or "in" "of"] form
  404.      &optional ["using" ([&or "key-code" "key-codes"
  405.                   "key-seq" "key-seqs"
  406.                   "key-binding" "key-bindings"] 
  407.              sexp)]]
  408.     ;; For arbitrary extensions, recognize anything else.
  409.     [symbolp &rest &or symbolp form]
  410.     ]
  411.    
  412.    ;; arithmetic - must be last since all parts are optional.
  413.    [[&optional [[&or "from" "downfrom" "upfrom"] form]]
  414.     [&optional [[&or "to" "downto" "upto" "below" "above"] form]]
  415.     [&optional ["by" form]]
  416.     ]))
  417.  
  418. (def-edebug-spec loop-initial-final
  419.   (&or ["initially" 
  420.     ;; [&optional &or "do" "doing"]  ;; CLtL2 doesnt allow this.
  421.     &rest loop-non-atomic-expr]
  422.        ["finally" &or 
  423.     [[&optional &or "do" "doing"] &rest loop-non-atomic-expr]
  424.     ["return" form]]))
  425.  
  426. (def-edebug-spec loop-and-clause
  427.   (loop-clause &rest ["and" loop-clause]))
  428.  
  429. (def-edebug-spec loop-clause
  430.   (&or
  431.    [[&or "while" "until" "always" "never" "thereis"] form]
  432.      
  433.    [[&or "collect" "collecting"
  434.      "append" "appending"
  435.      "nconc" "nconcing"
  436.      "concat" "vconcat"] form 
  437.      [&optional ["into" loop-var]]]
  438.  
  439.    [[&or "count" "counting"
  440.      "sum" "summing"
  441.      "maximize" "maximizing"
  442.      "minimize" "minimizing"] form
  443.      [&optional ["into" loop-var]]
  444.      loop-type-spec]
  445.  
  446.    [[&or "if" "when" "unless"]
  447.     form loop-and-clause
  448.     [&optional ["else" loop-and-clause]]
  449.     [&optional "end"]]
  450.  
  451.    [[&or "do" "doing"] &rest loop-non-atomic-expr]
  452.  
  453.    ["return" form]
  454.    loop-initial-final
  455.    ))
  456.  
  457. (def-edebug-spec loop-non-atomic-expr
  458.   ([¬ atom] form))
  459.  
  460. (def-edebug-spec loop-var
  461.   ;; The symbolp must be last alternative to recognize e.g. (a b . c)
  462.   ;; loop-var => 
  463.   ;; (loop-var . [&or nil loop-var])
  464.   ;; (symbolp . [&or nil loop-var])
  465.   ;; (symbolp . loop-var)
  466.   ;; (symbolp . (symbolp . [&or nil loop-var]))
  467.   ;; (symbolp . (symbolp . loop-var))
  468.   ;; (symbolp . (symbolp . symbolp)) == (symbolp symbolp . symbolp)
  469.   (&or (loop-var . [&or nil loop-var]) [gate symbolp]))
  470.  
  471. (def-edebug-spec loop-type-spec
  472.   (&optional ["of-type" loop-d-type-spec]))
  473.  
  474. (def-edebug-spec loop-d-type-spec
  475.   (&or (loop-d-type-spec . [&or nil loop-d-type-spec]) cl-type-spec))
  476.  
  477. ;; cl-specs.el ends here
  478.